class Vue {
    constructor(options) {
        this.$options = options || {}
        this.$data = options.data || {}
        this.$methods = options.methods || {}
        this.$el = typeof options.el === 'string' ? document.querySelector(options.el) : options.el

        this._proxyData(this.$data)
        this._methods(this.$methods)

        new Observer(this.$data)

        new Compiler(this)
    }

    _proxyData(data) {
        Object.keys(data).forEach(key => {
            Object.defineProperty(this, key, {
                get() {
                    return data[key]
                },
                set(value) {
                    if(value === data[key]) {
                        return
                    }

                    data[key] = value
                }
            })
        })
    }

    _methods(methods) {
        Object.keys(methods).forEach(method => {
            this[method] = methods[method]
        })
    }
}